fix(test): reject empty code get --out and strip code-file BOM#34
fix(test): reject empty code get --out and strip code-file BOM#34SahilRakhaiya05 wants to merge 2 commits into
Conversation
When test code get --out receives an empty inline body, closeOutputFile left a zero-byte file with exit 0 — scripts and agents treated that as a successful download. Abort the sink, unlink any artifact, and surface VALIDATION_ERROR instead. Plan/steps JSON already strip a leading UTF-8 BOM from PowerShell 5.1 files; apply the same strip to --code-file reads so uploaded test source is not corrupted by an invisible U+FEFF prefix.
Resolve conflicts in test.ts / test.test.ts by combining upstream's atomic temp-file --out writes with this branch's empty-code rejection (VALIDATION_ERROR exit 5) and BOM stripping. Update the pre-existing-file empty-code regression to expect exit 5 while still asserting the file is untouched.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Two silent-failure fixes in the test command surface:
1.
test code get --outwith empty inline codeWhen the API returns an empty/null
codebody in text mode, the CLI printed a stderr hint and exited 0 - but if--outwas set,closeOutputFile()still ran and left a zero-byte file. Agents and scripts checking file existence/size treated that as a successful download.Fix: abort the file sink, unlink any artifact, and throw
VALIDATION_ERROR(exit 5). Stderr-only text mode (no--out) behavior is unchanged.2. UTF-8 BOM on
--code-filePlan/steps JSON reads already strip a leading BOM from PowerShell 5.1
Set-Content -Encoding utf8files.readCodeFile()did not - the invisibleU+FEFFprefix was uploaded as part of the test source viatest code put/test create --code-file.Fix: apply existing
stripBom()inreadCodeFile().Tests
runCodeGet: empty inline code +--out? exit 5, no file left behind; stderr hint preserved without--outrunCodePut: BOM-prefixed code file uploads body without BOM